home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / intuition / modifyidcmp.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  4KB  |  127 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: modifyidcmp.c,v 1.3 1996/08/29 13:33:31 digulla Exp $
  4.     $Log: modifyidcmp.c,v $
  5.     Revision 1.3  1996/08/29 13:33:31  digulla
  6.     Moved common code from driver to Intuition
  7.     More docs
  8.  
  9.     Revision 1.2  1996/08/23 17:25:30  digulla
  10.     Added include intuition/intuition.h to user-docs
  11.  
  12.     Revision 1.1  1996/08/13 15:37:27  digulla
  13.     First function for intuition.library
  14.  
  15.  
  16.     Desc:
  17.     Lang: english
  18. */
  19. #include "intuition_intern.h"
  20. #include <clib/exec_protos.h>
  21.  
  22. /*****************************************************************************
  23.  
  24.     NAME */
  25.     #include <intuition/intuition.h>
  26.     #include <clib/intuition_protos.h>
  27.  
  28.     __AROS_LH2(BOOL, ModifyIDCMP,
  29.  
  30. /*  SYNOPSIS */
  31.     __AROS_LHA(struct Window *, window, A0),
  32.     __AROS_LHA(unsigned long  , flags, D0),
  33.  
  34. /*  LOCATION */
  35.     struct IntuitionBase *, IntuitionBase, 25, Intuition)
  36.  
  37. /*  FUNCTION
  38.     This routine modifies the state of your window's IDCMP (Intuition
  39.     Direct Communication Message Port).
  40.  
  41.     Depending on the current state in the IDCMPFlags of the window and
  42.     the specified flags these actions are possible:
  43.  
  44.     IDCMP    flags    Action
  45.       0      0    Nothing happens
  46.       0     !=0    The flags are copied in the IDCMPFlags of the window
  47.             and a MessagePort is created and stored in the
  48.             UserPort of the window.
  49.      !=0      0    The IDCMPFlags are cleared and the MessagePort in the
  50.             UserPort is deleted.
  51.      !=0     !=0    The flags are copied to the IDCMPFlags of the
  52.             window.
  53.  
  54.     INPUTS
  55.     window - The window to change the IDCMPFlags in.
  56.     flags - New flags for the IDCMPFlags of the window. See
  57.         intuition/intuition.h for the available flags.
  58.  
  59.     RESULT
  60.     TRUE if the change could be made and FALSE otherwise.
  61.  
  62.     NOTES
  63.     You can set up the Window->UserPort to any port of your own
  64.     before you call ModifyIDCMP().  If IDCMPFlags is non-null but
  65.     your UserPort is already initialized, Intuition will assume that
  66.     it's a valid port with task and signal data preset and Intuition
  67.     won't disturb your set-up at all, Intuition will just allocate
  68.     the Intuition message port half of it.    The converse is true
  69.     as well:  if UserPort is NULL when you call here with
  70.     IDCMPFlags == NULL, Intuition will deallocate only the Intuition
  71.     side of the port.
  72.  
  73.     This allows you to use a port that you already have allocated:
  74.  
  75.     - OpenWindow() with IDCMPFlags equal to NULL (open no ports)
  76.     - set the UserPort variable of your window to any valid port of your
  77.       own choosing
  78.     - call ModifyIDCMP with IDCMPFlags set to what you want
  79.     - then, to clean up later, set UserPort equal to NULL before calling
  80.       CloseWindow() (leave IDCMPFlags alone)  BUT FIRST: you must make
  81.       sure that no messages sent your window are queued at the port,
  82.       since they will be returned to the memory free pool.
  83.  
  84.     For an example of how to close a window with a shared IDCMP,
  85.     see the description for CloseWindow().
  86.  
  87.     EXAMPLE
  88.  
  89.     BUGS
  90.  
  91.     SEE ALSO
  92.     OpenWindow(), CloseWindow()
  93.  
  94.     INTERNALS
  95.  
  96.     HISTORY
  97.     29-10-95    digulla automatically created from
  98.                 intuition_lib.fd and clib/intuition_protos.h
  99.  
  100. *****************************************************************************/
  101. {
  102.     __AROS_FUNC_INIT
  103.     __AROS_BASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  104.  
  105.     if (!window->IDCMPFlags && flags)
  106.     {
  107.     window->UserPort = CreateMsgPort ();
  108.  
  109.     if (!window->UserPort)
  110.         return FALSE;
  111.     }
  112.  
  113.     window->IDCMPFlags = flags;
  114.  
  115.     if (!flags)
  116.     {
  117.     if (window->UserPort)
  118.     {
  119.         DeleteMsgPort (window->UserPort);
  120.         window->UserPort = NULL;
  121.     }
  122.     }
  123.  
  124.     return TRUE;
  125.     __AROS_FUNC_EXIT
  126. } /* ModifyIDCMP */
  127.